# -*- Python -*-

# Configuration file for the 'lit' test runner.

import os

import lit.formats

# name: The name of this test suite.
config.name = 'llbuild-unit'

# suffixes: A list of file extensions to treat as test files.
config.suffixes = []

# test_source_root: The root path where tests are located.
# test_exec_root: The root path where tests should be run.
llbuild_obj_root = getattr(config, 'llbuild_obj_root', None)
if llbuild_obj_root is not None:
    config.test_exec_root = os.path.join(llbuild_obj_root, 'bin')
    config.test_source_root = config.test_exec_root

# testFormat: The test format to use to interpret tests.
llbuild_build_mode = getattr(config, 'llbuild_build_mode', "Debug")
config.test_format = lit.formats.GoogleTest(llbuild_build_mode, 'Tests')

# Propagate LLVM_PROFILE_FILE if used.
llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE")
if llvm_profile_file:
    config.environment["LLVM_PROFILE_FILE"] = llvm_profile_file

# Propagate the temp directory. Windows requires this because it uses \Windows\
# if none of these are present.
if 'TMP' in os.environ:
    config.environment['TMP'] = os.environ['TMP']
if 'TEMP' in os.environ:
    config.environment['TEMP'] = os.environ['TEMP']

if 'DYLD_LIBRARY_PATH' in os.environ:
    config.environment['DYLD_LIBRARY_PATH'] = os.environ['DYLD_LIBRARY_PATH']

# Define the folder that contains the dlls created during the build.
config.shlibdir = llbuild_obj_root

# Win32 seeks DLLs along %PATH%.
if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
    config.environment['PATH'] = os.path.pathsep.join((
            config.shlibdir, config.environment['PATH']))
